Ejemplo n.º 1
0
    def test_with_tocken(self):
        auth = Auth(token=generate_token())

        # If the request is sent successfully, then I expect a response to
        # be returned.
        self.assertIsInstance(auth.__str__(), str)
        self.assertFalse(auth.is_expired())
Ejemplo n.º 2
0
    def test_login(self):
        # Call the service, which will send a request to the server.
        auth = Auth(user='******', password='******')

        # If the request is sent successfully, then I expect a response to
        # be returned.
        self.assertIsInstance(auth.__str__(), str)
        self.assertFalse(auth.is_expired())
Ejemplo n.º 3
0
    def test_expired(self):
        self.mock_get.return_value = Mock()
        self.mock_get.return_value.text = generate_token(
            now=self.now-10000)
        self.mock_get.return_value.status_code = 200

        # Call the service, which will send a request to the server.
        auth = Auth(user='******', password='******')

        self.assertIsInstance(auth.__str__(), str)
        self.assertTrue(auth.is_expired())
Ejemplo n.º 4
0
    def setUp(self):
        self.auth = Auth(token=generate_token())

        with open(os.path.join(data_path, "sample2.json")) as handle:
            self.data = json.load(handle)

        self.sample = Sample(self.auth, data=self.data)
Ejemplo n.º 5
0
    def setUp(self):
        self.auth = Auth(token=generate_token())

        with open(os.path.join(data_path, "team.json")) as handle:
            data = json.load(handle)

        self.team = Team(self.auth, data=data)
Ejemplo n.º 6
0
    def test_get_durations(self):
        self.mock_get.return_value = Mock()
        self.mock_get.return_value.text = generate_token(
            now=self.now-3300)
        self.mock_get.return_value.status_code = 200

        # Call the service, which will send a request to the server.
        auth = Auth(user='******', password='******')

        # get duration
        duration = auth.get_duration()

        # get remaining seconds
        seconds = int(duration.total_seconds())

        self.assertAlmostEqual(seconds, 300, delta=10)
Ejemplo n.º 7
0
    def setUp(self):
        self.auth = Auth(token=generate_token())

        with open(os.path.join(data_path, "root.json")) as handle:
            data = json.load(handle)

        self.mock_get.return_value = Mock()
        self.mock_get.return_value.json.return_value = data
        self.mock_get.return_value.status_code = 200

        # get a root object
        self.root = Root(self.auth)
Ejemplo n.º 8
0
    def setUp(self):
        self.auth = Auth(token=generate_token())
        self.user = User(self.auth)

        self.data = {
            "userName": "******",
            "email": "*****@*****.**",
            "userReference": "usr-f1801430-51e1-4718-8fca-778887087bad",
            "_links": {
                "self": {
                    "href":
                    "https://explore.api.aai.ebi.ac.uk/users/usr-"
                    "f1801430-51e1-4718-8fca-778887087bad"
                }
            }
        }
Ejemplo n.º 9
0
    def setUp(self):
        self.auth = Auth(token=generate_token())

        with open(os.path.join(data_path, "newSubmission.json")) as handle:
            data = json.load(handle)

        self.submission = Submission(self.auth, data=data)

        with open(os.path.join(data_path, "contents.json")) as handle:
            self.content = json.load(handle)

        # defining samples
        self.sample1 = {
            'alias': 'animal_1',
            'title': 'animal_title',
            'releaseDate': '2018-07-13',
            'taxonId': 9940,
            'attributes': {
                'material': [{
                    'value':
                    'organism',
                    'terms': [{
                        'url':
                        'http://purl.obolibrary.org/obo/OBI_0100026'
                    }]
                }],
                'project': [{
                    'value': 'test'
                }]
            },
            'sampleRelationships': []
        }

        self.sample2 = {
            'alias':
            'sample_1',
            'title':
            'sample_title',
            'releaseDate':
            '2018-07-13',
            'taxonId':
            9940,
            'description':
            'a description',
            'attributes': {
                'material': [{
                    'value':
                    'specimen from organism',
                    'terms': [{
                        'url':
                        'http://purl.obolibrary.org/obo/OBI_0001479'
                    }]
                }],
                'project': [{
                    'value': 'test'
                }]
            },
            'sampleRelationships': [{
                'alias': 'animal_1',
                'relationshipNature': 'derived from'
            }]
        }
Ejemplo n.º 10
0
 def setUp(self):
     self.auth = Auth(token=generate_token())
     self.domain = Domain(self.auth)
Ejemplo n.º 11
0
    def test_get_tocken(self):
        # Call the service, which will send a request to the server.
        auth = Auth(user='******', password='******')
        token = auth.token

        self.assertIsInstance(token, str)