-
Notifications
You must be signed in to change notification settings - Fork 686
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11483 from bjester/studio-syncless
Avoid syncing with non-kolibris
- Loading branch information
Showing
7 changed files
with
131 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
""" | ||
Subset of Users Device (SOUD) tests | ||
""" | ||
import uuid | ||
|
||
from django.test import TestCase | ||
|
||
from ..soud import Context | ||
from kolibri.core.discovery.models import ConnectionStatus | ||
from kolibri.core.discovery.models import StaticNetworkLocation | ||
|
||
|
||
class SoudContextTestCase(TestCase): | ||
def setUp(self): | ||
super(SoudContextTestCase, self).setUp() | ||
self.context = Context(uuid.uuid4().hex, uuid.uuid4().hex) | ||
|
||
def test_property__network_location(self): | ||
netloc = StaticNetworkLocation.objects.create( | ||
base_url="https://kolibrihappyurl.qqq/", | ||
connection_status=ConnectionStatus.Okay, | ||
application="kolibri", | ||
instance_id=self.context.instance_id, | ||
) | ||
self.assertEqual(self.context.network_location, netloc) | ||
|
||
def test_property__network_location__not_kolibri(self): | ||
StaticNetworkLocation.objects.create( | ||
base_url="https://kolibrihappyurl.qqq/", | ||
connection_status=ConnectionStatus.Okay, | ||
application="studio", | ||
instance_id=self.context.instance_id, | ||
) | ||
self.assertIsNone(self.context.network_location) | ||
|
||
def test_property__network_location__not_connected(self): | ||
StaticNetworkLocation.objects.create( | ||
base_url="https://kolibrihappyurl.qqq/", | ||
connection_status=ConnectionStatus.ConnectionFailure, | ||
application="kolibri", | ||
instance_id=self.context.instance_id, | ||
) | ||
self.assertIsNone(self.context.network_location) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from django.test import TestCase | ||
|
||
from ..models import ConnectionStatus | ||
from ..models import DynamicNetworkLocation | ||
from ..models import LocationTypes | ||
from ..models import NetworkLocation | ||
from ..models import StaticNetworkLocation | ||
|
||
|
||
class NetworkLocationTestCase(TestCase): | ||
multi_db = True | ||
|
||
def test_property__available(self): | ||
location = NetworkLocation() | ||
self.assertFalse(location.available) | ||
location.connection_status = ConnectionStatus.Okay | ||
self.assertFalse(location.available) | ||
location.base_url = "https://kolibrihappyurl.qqq/" | ||
self.assertTrue(location.available) | ||
location.connection_status = ConnectionStatus.ConnectionFailure | ||
self.assertFalse(location.available) | ||
|
||
def test_property__is_kolibri(self): | ||
location = NetworkLocation() | ||
self.assertFalse(location.is_kolibri) | ||
location.application = "kdp" | ||
self.assertFalse(location.is_kolibri) | ||
location.application = "kolibri" | ||
self.assertTrue(location.is_kolibri) | ||
|
||
def test_property__dynamic(self): | ||
static = StaticNetworkLocation() | ||
self.assertFalse(static.dynamic) | ||
dynamic = DynamicNetworkLocation() | ||
self.assertTrue(dynamic.dynamic) | ||
reserved = NetworkLocation(location_type=LocationTypes.Reserved) | ||
self.assertFalse(reserved.dynamic) | ||
|
||
def test_property__reserved(self): | ||
static = StaticNetworkLocation() | ||
self.assertFalse(static.reserved) | ||
dynamic = DynamicNetworkLocation() | ||
self.assertFalse(dynamic.reserved) | ||
reserved = NetworkLocation(location_type=LocationTypes.Reserved) | ||
self.assertTrue(reserved.reserved) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters