How to test if a number is a primitive root? How to test if a number is a primitive root, assuming the $\text{mod}\enspace m$ where $m$ is a prime? And if not?

Is it not enough if the number is relatively prime to the modulus or prime?

I'll write down what I've done and would like to know if I'm right:

I tested if the modulus is prime with the Rabin-miller test. It was prime, so I used python program to factor $m-1$ since $\phi(m) = m - 1$. It printed out $2$ and another prime. So then I calculated $g ^ q \bmod (m-1)$ for all factors where $q$ is the factor and they were $\neq 1$. So $g$ should be a generator, right?
For all $m$, if $m$ is a positive integer then

$g$ is a primitive root mod $m$ $\;$ if and only if

$0\leq g&lt; m$ $\:$ and $\:$ $\operatorname{gcd}(\hspace{.015 in}g,\hspace{-0.01 in}m) = 1$ $\:$ and $\;\;$ for all prime factors $q$ of $\phi$$(m)$, $\: g^{(\phi(m))/q} \not\equiv 1 \pmod m$.