def create_test_users_locations():

    test_objects = {
        'location-public-1':
        Location.objects.create(slug='location-public-1',
                                name='location-public-1',
                                min_depth=1.0,
                                under_keal=2.0,
                                visible=True),
        'location-private-1':
        Location.objects.create(slug='location-private-1',
                                name='location-private-1',
                                min_depth=1.0,
                                under_keal=2.0,
                                visible=False),
        'location-private-2':
        Location.objects.create(slug='location-private-2',
                                name='location-private-2',
                                min_depth=1.0,
                                under_keal=2.0,
                                visible=False),
    }

    test_objects['user-1'] = create_user(
        'user-1', available_locations=[test_objects['location-private-1']])

    test_objects['user-collector'] = create_user('user-collector',
                                                 is_internal_collector=True)

    return test_objects
    def setUpClass(cls):
        TideGauge.objects.all().delete()
        TideGauge.objects.create(slug='gladstone')
        cls.permitted = create_user(
            'permitted', is_internal_collector=True)

        cls.forbidden = create_user(
            'forbidden', is_internal_collector=False)
    def setUpClass(cls):
        cls.gladstone = TideGauge.objects.create(slug='gladstone')

        cls.normal_user = create_user(
            'user-normal', is_internal_collector=False)

        cls.collector_user = create_user(
            'user-collector', is_internal_collector=True)
Exemplo n.º 4
0
    def setUpClass(cls):
        cls.liverpool = cls.create_location()
        cls.location = cls.liverpool
        cls.permitted = create_user('permitted', is_internal_collector=True)
        cls.user = create_user('user', is_internal_collector=False)
        cls.forbidden = create_user('forbidden', is_internal_collector=False)

        cls.good_data = PREDICTION_WEATHER
Exemplo n.º 5
0
    def setUp(self):
        super(TestInvite, self).setUp()
        self.valid_user = create_user('valid_user',
                                      is_internal_collector=False)
        self.valid_user.email = '*****@*****.**'
        self.valid_user.save()

        self.invalid_user = create_user('invalid_user',
                                        is_internal_collector=False)
Exemplo n.º 6
0
    def setUpClass(cls):
        cls.liverpool = cls.create_location()
        cls.permitted = create_user('permitted', is_internal_collector=True)
        cls.forbidden = create_user('forbidden', is_internal_collector=False)

        cls.good_data = {
            "datetime": "2014-06-10T10:34:00Z",
            "surge_level": 0.23
        }
Exemplo n.º 7
0
    def setUpClass(cls, url, good_data):
        super(ViewAuthenticationTest, cls).setUpClass()

        cls.url = url

        cls.permitted = create_user('permitted', is_internal_collector=True)
        cls.forbidden = create_user('forbidden', is_internal_collector=False)

        cls.good_data = good_data
Exemplo n.º 8
0
 def setUpClass(cls):
     super(TestSchedule, cls).setUpClass()
     cls.permitted = create_user('permitted', is_internal_collector=True)
     cls.forbidden = create_user('forbidden', is_internal_collector=False)
     cls.token_permitted, _ = Token.objects.get_or_create(
         user=cls.permitted)
     cls.token_forbidden, _ = Token.objects.get_or_create(
         user=cls.forbidden)
     cls.token = cls.token_permitted
 def setUp(self):
     super(TestNotification, self).setUp()
     self.permitted = create_user('permitted', is_internal_collector=True)
     self.forbidden = create_user('forbidden', is_internal_collector=False)
     self.token_permitted, _ = Token.objects.get_or_create(
         user=self.permitted)
     self.token_forbidden, _ = Token.objects.get_or_create(
         user=self.forbidden)
     self.token = self.token_permitted
     self.setUpNotificationRequirements()
Exemplo n.º 10
0
    def setUpClass(cls):
        cls.liverpool = cls.create_location()
        cls.permitted = create_user('permitted', is_internal_collector=True)
        cls.forbidden = create_user('forbidden', is_internal_collector=False)

        cls.good_data = {
            "datetime": "2014-06-10T10:34:00Z",
            "surge_level": 0.23,
            "provider": "met_office",
        }
Exemplo n.º 11
0
 def test_that_email_unique(self):
     user2 = create_user('sampleuser2')
     with self.assertRaises(ValidationError) as ex:
         user2.email = self.user.email
         user2.save()
     msg = "Email {0} is already used".format(user2.email)
     self.assertEquals(msg, ex.exception.message)
     user2.delete()
Exemplo n.º 12
0
 def test_that_email_unique(self):
     user2 = create_user('sampleuser2')
     with self.assertRaises(ValidationError) as ex:
         user2.email = self.user.email
         user2.save()
     msg = "Email {0} is already used".format(user2.email)
     self.assertEquals(msg, ex.exception.message)
     user2.delete()
    def setUp(self):
        super(TestLocationListFiltering, self).setUp()
        self.user_collector = create_user(
            'user-collector', is_internal_collector=True)
        self.location_public = self.create_location(slug='public-1',
                                                    visible=True)
        self.location_private_1 = self.create_location(slug='private-1',
                                                       visible=False)
        self.location_private_2 = self.create_location(slug='private-2',
                                                       visible=False)
        self.user_1 = create_user(
            'user-1', available_locations=[self.location_private_1])

        self.user_2 = create_user(
            'user-2',
            available_locations=[
                self.location_private_1, self.location_private_2]
        )
Exemplo n.º 14
0
    def setUp(self):
        super(TestLocationListFiltering, self).setUp()
        self.user_collector = create_user('user-collector',
                                          is_internal_collector=True)
        self.location_public = self.create_location(slug='public-1',
                                                    visible=True)
        self.location_private_1 = self.create_location(slug='private-1',
                                                       visible=False)
        self.location_private_2 = self.create_location(slug='private-2',
                                                       visible=False)
        self.user_1 = create_user(
            'user-1', available_locations=[self.location_private_1])

        self.user_2 = create_user('user-2',
                                  available_locations=[
                                      self.location_private_1,
                                      self.location_private_2
                                  ])
def create_test_users_locations():

    test_objects = {
        'location-public-1': Location.objects.create(
            slug='location-public-1',
            name='location-public-1',
            min_depth=1.0,
            under_keal=2.0,
            visible=True),

        'location-private-1': Location.objects.create(
            slug='location-private-1',
            name='location-private-1',
            min_depth=1.0,
            under_keal=2.0,
            visible=False),

        'location-private-2': Location.objects.create(
            slug='location-private-2',
            name='location-private-2',
            min_depth=1.0,
            under_keal=2.0,
            visible=False),
    }

    test_objects['user-1'] = create_user(
        'user-1',
        available_locations=[test_objects['location-private-1']]
    )

    test_objects['user-collector'] = create_user(
        'user-collector',
        is_internal_collector=True
    )

    return test_objects
Exemplo n.º 16
0
    def test_no_timeout_token_doesnt_expire(self):
        user = create_user('noexpireuser')
        user.email = '*****@*****.**'
        profile = user.user_profile
        profile.codes_timeout = False
        profile.save()
        user.save()

        token = TokenBackend.create_token(user)
        response = self.postAuthCode(token.code)
        self.assertEqual(response.status_code, 200)

        response = self.postAuthCode(token.code)
        self.assertEqual(response.status_code, 200)
        token.delete()
        user.delete()
    def test_no_timeout_token_doesnt_expire(self):
        user = create_user('noexpireuser')
        user.email = '*****@*****.**'
        profile = user.user_profile
        profile.codes_timeout = False
        profile.save()
        user.save()

        token = TokenBackend.create_token(user)
        response = self.postAuthCode(token.code)
        self.assertEqual(response.status_code, 200)

        response = self.postAuthCode(token.code)
        self.assertEqual(response.status_code, 200)
        token.delete()
        user.delete()
Exemplo n.º 18
0
    def setUpClass(cls):
        cls.liverpool = cls.create_location()

        cls.PREDICTION_A = {
            "datetime": "2014-06-10T10:34:00Z",
            "surge_level": 0.23
        }

        cls.PREDICTION_B = {
            "datetime": "2014-06-10T10:34:00Z",  # same as A
            "surge_level": -0.15
        }

        cls.PREDICTION_C = {
            "datetime": "2014-06-10T11:00:00Z",
            "surge_level": 0.50
        }
        cls.user = create_user('collector', is_internal_collector=True)
Exemplo n.º 19
0
    def setUpClass(cls):
        TideGauge.objects.all().delete()
        TideGauge.objects.create(slug='gladstone')
        cls.permitted = create_user('permitted', is_internal_collector=True)

        cls.forbidden = create_user('forbidden', is_internal_collector=False)
Exemplo n.º 20
0
 def setUpClass(cls):
     super(TestWeatherView, cls).setUpClass()
     cls.user = create_user('collector', is_internal_collector=True)
     cls.liverpool = cls.create_location()
     cls.location = cls.liverpool
Exemplo n.º 21
0
 def setUp(self):
     super(TestAuthentication, self).setUp()
     self.user = create_user('sampleuser')
     self.user.email = '*****@*****.**'
     self.user.save()
Exemplo n.º 22
0
 def setUp(self):
     super(TestAuthentication, self).setUp()
     self.user = create_user('sampleuser')
     self.user.email = '*****@*****.**'
     self.user.save()
Exemplo n.º 23
0
 def setUp(self):
     super(FunctionalTest, self).setUp()
     self.user = create_user('permitted', is_internal_collector=True)
Exemplo n.º 24
0
 def setUp(self):
     super(FunctionalTest, self).setUp()
     self.user = create_user('permitted', is_internal_collector=True)
Exemplo n.º 25
0
 def setUpClass(cls):
     super(TestWeatherView, cls).setUpClass()
     cls.user = create_user('collector',
                            '*****@*****.**',
                            is_internal_collector=True)
Exemplo n.º 26
0
 def setUpClass(cls):
     super(TestWeatherView, cls).setUpClass()
     cls.user = create_user('collector',
                            '*****@*****.**',
                            is_internal_collector=True)
Exemplo n.º 27
0
 def setUpClass(cls):
     cls.liverpool = cls.create_location()
     cls.user = create_user('collector', is_internal_collector=True)