Beispiel #1
0
 def test_delete_facility_map_cascade(self) -> None:
     """Create a new user, with facility, then remove."""
     assert User.count() == 4 and Facility.count(
     ) == 4 and FacilityMap.count() == 4
     User.add({
         'first_name': 'James',
         'last_name': 'Bond',
         'email': '*****@*****.**',
         'alias': '007',
         'data': {
             'user_type': 'amateur',
             'drink_of_choice': 'martini'
         }
     })
     user = User.from_alias('007')
     Facility.add({
         'name': 'Bond_4m',
         'latitude': -25.5,
         'longitude': -69.25,
         'elevation': 5050,
         'limiting_magnitude': 17.5,
         'data': {
             'telescope_design': 'reflector'
         }
     })
     facility = Facility.from_name('Bond_4m')
     user.add_facility(facility.id)
     assert user.facilities()[0].to_dict() == facility.to_dict()
     assert User.count() == 5 and Facility.count(
     ) == 5 and FacilityMap.count() == 5
     User.delete(user.id)
     assert User.count() == 4 and Facility.count(
     ) == 5 and FacilityMap.count() == 4
     Facility.delete(facility.id)
     assert Facility.count() == 4
Beispiel #2
0
 def test_delete_client_cascade(self) -> None:
     """Add a new user, client, and session. Remove user to clear client and session."""
     assert User.count() == 4 and Client.count() == 4 and Session.count(
     ) == 4
     user = User.add({
         'first_name': 'James',
         'last_name': 'Bond',
         'email': '*****@*****.**',
         'alias': '007',
         'data': {
             'user_type': 'amateur',
             'drink_of_choice': 'martini'
         }
     })
     assert User.count() == 5 and Client.count() == 4 and Session.count(
     ) == 4
     Client.new(user.id)
     assert User.count() == 5 and Client.count() == 5 and Session.count(
     ) == 4
     Session.new(user.id)
     assert User.count() == 5 and Client.count() == 5 and Session.count(
     ) == 5
     User.delete(user.id)
     assert User.count() == 4 and Client.count() == 4 and Session.count(
     ) == 4
Beispiel #3
0
 def test_delete_user_cascade(self) -> None:
     """Add a new user and client record and then remove them."""
     assert User.count() == 4 and Client.count() == 4
     user = User.add({'first_name': 'James', 'last_name': 'Bond', 'email': '*****@*****.**',
                      'alias': '007', 'data': {'user_type': 'amateur', 'drink_of_choice': 'martini'}})
     assert User.count() == 5 and Client.count() == 4
     Client.new(user.id)
     assert User.count() == 5 and Client.count() == 5
     User.delete(user.id)
     assert User.count() == 4 and Client.count() == 4
Beispiel #4
0
 def test_delete_facility_map_cascade(self) -> None:
     """Create a new facility, associate it with a user, then remove."""
     assert User.count() == 4 and Facility.count() == 4 and FacilityMap.count() == 4
     Facility.add({'name': 'Bourne_4m', 'latitude': -24.5, 'longitude': -69.25, 'elevation': 5050,
                   'limiting_magnitude': 17.5, 'data': {'telescope_design': 'reflector'}})
     facility = Facility.from_name('Bourne_4m')
     user = User.from_alias('delta_one')
     user.add_facility(facility.id)
     assert User.count() == 4 and Facility.count() == 5 and FacilityMap.count() == 5
     Facility.delete(facility.id)
     assert User.count() == 4 and Facility.count() == 4 and FacilityMap.count() == 4
Beispiel #5
0
 def test_delete(self) -> None:
     """Add a new user and client. Remove the client directly."""
     assert User.count() == 4 and Client.count() == 4
     user = User.add({'first_name': 'James', 'last_name': 'Bond', 'email': '*****@*****.**',
                      'alias': '007', 'data': {'user_type': 'amateur', 'drink_of_choice': 'martini'}})
     assert User.count() == 5 and Client.count() == 4
     key, secret, client = Client.new(user.id)
     assert User.count() == 5 and Client.count() == 5
     Client.delete(client.id)
     assert User.count() == 5 and Client.count() == 4
     User.delete(user.id)
     assert User.count() == 4 and Client.count() == 4
Beispiel #6
0
 def test_delete(self) -> None:
     """Add a new user record and then remove it."""
     assert User.count() == 4
     User.add({
         'first_name': 'James',
         'last_name': 'Bond',
         'email': '*****@*****.**',
         'alias': '007',
         'data': {
             'user_type': 'amateur',
             'drink_of_choice': 'martini'
         }
     })
     assert User.count() == 5
     assert User.from_alias('007').last_name == 'Bond'
     User.delete(User.from_alias('007').id)
     assert User.count() == 4
Beispiel #7
0
 def test_delete(self) -> None:
     """Add a new session and remove it directly."""
     assert User.count() == 4 and Client.count() == 4 and Session.count(
     ) == 4
     user = User.add({
         'first_name': 'James',
         'last_name': 'Bond',
         'email': '*****@*****.**',
         'alias': '007',
         'data': {
             'user_type': 'amateur',
             'drink_of_choice': 'martini'
         }
     })
     assert User.count() == 5 and Client.count() == 4 and Session.count(
     ) == 4
     key, secret, client = Client.new(user.id)
     assert User.count() == 5 and Client.count() == 5 and Session.count(
     ) == 4
     Session.new(user.id)
     assert User.count() == 5 and Client.count() == 5 and Session.count(
     ) == 5
     Session.delete(Session.from_client(client.id).id)
     assert User.count() == 5 and Client.count() == 5 and Session.count(
     ) == 4
     User.delete(user.id)  # NOTE: deletes client
     assert User.count() == 4 and Client.count() == 4 and Session.count(
     ) == 4