Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Commit

Permalink
Tidy up feature imports
Browse files Browse the repository at this point in the history
- Move `api_common` module from steps to support as it contains no steps
- Rearrange all imports to:
  - Use relative imports where appropriate
  - Separate imports into system, 3rd party and local
  - Alphabetise imports within each group
  • Loading branch information
robyoung committed May 18, 2014
1 parent 29bd97e commit 763310d
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 21 deletions.
5 changes: 3 additions & 2 deletions features/environment.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import logging
import os
import sys
from features.support.splinter_client import SplinterClient

from features.support.stagecraft import stop_stagecraft_service_if_running
from .support.splinter_client import SplinterClient
from .support.stagecraft import stop_stagecraft_service_if_running


sys.path.append(
os.path.join(os.path.dirname(__file__), '..')
Expand Down
3 changes: 2 additions & 1 deletion features/steps/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from behave import given
import os
import shutil

from behave import given


@given(u'a file named "{filename}" with fixture "{fixturename}"')
def step(context, filename, fixturename):
Expand Down
5 changes: 3 additions & 2 deletions features/steps/authentication.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from behave import *
from ..support.authentication import \
from behave import given

from features.support.authentication import \
ensure_user_has_permissions, ensure_user_exists


Expand Down
9 changes: 6 additions & 3 deletions features/steps/read_api.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import datetime
import os
import re

from behave import given, when, then, step_matcher
from dateutil import parser
from flask import json
from hamcrest import assert_that, is_, matches_regexp, has_length, equal_to, \
has_item, has_entries, has_entry
from dateutil import parser
import datetime
import pytz
from api_common import ensure_data_set_exists

from features.support.api_common import ensure_data_set_exists
from features.support.stagecraft import create_or_update_stagecraft_service


FIXTURE_PATH = os.path.join(os.path.dirname(__file__), '..', 'fixtures')
Expand Down
7 changes: 5 additions & 2 deletions features/steps/splinter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import json
import datetime
from hamcrest import *
import json

from behave import when, when
from hamcrest import contains_inanyorder, has_items, has_entries, \
assert_that, is_

from backdrop.core.timeutils import utc

Expand Down
2 changes: 2 additions & 0 deletions features/steps/write_api.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import os

from behave import given, when, then
from dateutil import parser
from hamcrest import assert_that, has_length, equal_to


FIXTURE_PATH = os.path.join(os.path.dirname(__file__), '..', 'fixtures')


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from features.support.stagecraft import create_or_update_stagecraft_service
from .stagecraft import create_or_update_stagecraft_service


TEST_STAGECRAFT_PORT = 3204

Expand Down
2 changes: 1 addition & 1 deletion features/support/authentication.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from stagecraft import create_or_update_stagecraft_service
from .stagecraft import create_or_update_stagecraft_service


TEST_STAGECRAFT_PORT = 3204
Expand Down
2 changes: 1 addition & 1 deletion features/support/flask_test_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from features.support.support import BaseClient
from .support import BaseClient


class FlaskTestClient(BaseClient):
Expand Down
3 changes: 2 additions & 1 deletion features/support/http_test_client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pymongo import MongoClient
import requests
from features.support.support import FlaskApp, BaseClient

from .support import FlaskApp, BaseClient


class HTTPTestClient(BaseClient):
Expand Down
11 changes: 6 additions & 5 deletions features/support/splinter_client.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from datetime import datetime
import logging

from pymongo import MongoClient
from splinter import Browser

from features.support.support import FlaskApp, BaseClient
from .support import FlaskApp, BaseClient


logger = logging.getLogger(__name__)
log = logging.getLogger(__name__)


class SplinterClient(BaseClient):
Expand Down Expand Up @@ -41,11 +42,11 @@ def _save_screenshot(self, filename):
try:
success = self.browser.driver.save_screenshot(filename)
if not success:
logger.warn(
log.warn(
"Unable to save screenshot %s: IO error" % filename)
except Exception as e:
logger.warn("Unable to save screenshot %s: Exception" % filename)
logger.warn(e)
log.warn("Unable to save screenshot %s: Exception" % filename)
log.warn(e)


class SplinterResponse:
Expand Down
4 changes: 2 additions & 2 deletions features/support/stagecraft.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os
from multiprocessing import Process

from flask import Flask, Response, abort, json, request
from multiprocessing import Process
import requests

from features.support.support import wait_until
from .support import wait_until


def create_or_update_stagecraft_service(context, port, routes):
Expand Down
1 change: 1 addition & 0 deletions features/support/support.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import subprocess
import time

import requests


Expand Down

0 comments on commit 763310d

Please sign in to comment.