import time
import subprocess
import pytest
import sys

SOURCE = "**"
if len(sys.argv) == 2:
    SOURCE = str(sys.argv[1])

start = subprocess.Popen(['make', 'backend'])
time.sleep(5)
process = subprocess.run("pytest augur/datasources/{}/test_{}_routes.py".format(SOURCE, SOURCE), shell=True)
time.sleep(2)
subprocess.Popen(['make', 'backend-stop'])

sys.exit(process.returncode)

import time
import subprocess
import os
import pytest
import sys

SOURCE = "**"
if len(sys.argv) == 2:
    SOURCE = str(sys.argv[1])

FNULL = open(os.devnull, 'w')

start = subprocess.Popen(['augur', 'run'], stdout=FNULL, stderr=subprocess.STDOUT)
time.sleep(20)
process = subprocess.run("pytest augur/datasources/{}/test_{}_routes.py".format(SOURCE, SOURCE), shell=True)
time.sleep(5)
subprocess.Popen(['make', 'backend-stop'])

sys.exit(process.returncode)

Refactor API testing script to be consistent with Travis build
Refactor API testing script to be consistent with Travis build

Signed-off-by: Carter Landis <ffc486ac0b21a34cfd7d1170183ed86b0f1b04a2@gmail.com>

  import time
  import subprocess
+ import os
  import pytest
  import sys
  
  SOURCE = "**"
  if len(sys.argv) == 2:
      SOURCE = str(sys.argv[1])
  
- start = subprocess.Popen(['make', 'backend'])
+ FNULL = open(os.devnull, 'w')
+ 
+ start = subprocess.Popen(['augur', 'run'], stdout=FNULL, stderr=subprocess.STDOUT)
+ time.sleep(20)
+ process = subprocess.run("pytest augur/datasources/{}/test_{}_routes.py".format(SOURCE, SOURCE), shell=True)
  time.sleep(5)
- process = subprocess.run("pytest augur/datasources/{}/test_{}_routes.py".format(SOURCE, SOURCE), shell=True)
- time.sleep(2)
  subprocess.Popen(['make', 'backend-stop'])
  
  sys.exit(process.returncode)
  
Refactor API testing script to be consistent with Travis build
## Code Before:
import time
import subprocess
import pytest
import sys

SOURCE = "**"
if len(sys.argv) == 2:
    SOURCE = str(sys.argv[1])

start = subprocess.Popen(['make', 'backend'])
time.sleep(5)
process = subprocess.run("pytest augur/datasources/{}/test_{}_routes.py".format(SOURCE, SOURCE), shell=True)
time.sleep(2)
subprocess.Popen(['make', 'backend-stop'])

sys.exit(process.returncode)

## Instruction:
Refactor API testing script to be consistent with Travis build
## Code After:
import time
import subprocess
import os
import pytest
import sys

SOURCE = "**"
if len(sys.argv) == 2:
    SOURCE = str(sys.argv[1])

FNULL = open(os.devnull, 'w')

start = subprocess.Popen(['augur', 'run'], stdout=FNULL, stderr=subprocess.STDOUT)
time.sleep(20)
process = subprocess.run("pytest augur/datasources/{}/test_{}_routes.py".format(SOURCE, SOURCE), shell=True)
time.sleep(5)
subprocess.Popen(['make', 'backend-stop'])

sys.exit(process.returncode)
