-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* models for version creation and storage * working PackageVersion models with basic tests * More testing, TODO: More granular versioning * TODO: How to navigate different versions * PV now ID-ed with ForeignKey, added summary field for PVs * PR comment edits * Delete 0001_initial.py * Delete 0002_auto_20180304_0020.py * Delete 0003_package_data.py * Delete 0004_auto_20180509_0218.py * Delete 0005_auto_20180509_0608.py * Delete 0006_auto_20180516_0325.py * Delete 0007_auto_20180516_0328.py * Delete 0008_packageversion_version_description.py * Delete 0001_squashed_0009_auto_20180517_0135.py * Add files via upload * new migration * unbroke migrations * fix migrations * fixed creator foreignKey, updated tests * Delete 0004_auto_20180517_1807.py * fixed latest_version fKey to point to PV instance * Add files via upload * new migration * fix migrations * Delete 0004_auto_20180517_1807.py * 'big-branch-update' * 'gitignore-bundles' * 'ignore-bundles' * remove assets * remove packages folder
- Loading branch information
1 parent
27fa289
commit a2523d6
Showing
6 changed files
with
76 additions
and
10 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,14 @@ | ||
# Generated by Django 2.0.2 on 2018-10-03 02:52 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('packages', '0005_auto_20180523_0211'), | ||
('packages', '0005_auto_20180530_0148'), | ||
] | ||
|
||
operations = [ | ||
] |
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,14 @@ | ||
# Generated by Django 2.1 on 2018-10-13 05:14 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('packages', '0006_merge_20181003_0252'), | ||
('packages', '0007_auto_20181012_0142'), | ||
] | ||
|
||
operations = [ | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,36 @@ | ||
from django.contrib.auth.models import User | ||
from django.test import TestCase | ||
from .models import PackageVersion, Package, PackageSet | ||
|
||
# Create your tests here. | ||
class PackageVersionTestCase(TestCase): | ||
def setUp(self): | ||
PackageSet.objects.create(slug="TestSet") | ||
Package.objects.create(slug="a", cached_article_preview="Hong Yi", publish_date="2018-5-8", package_set_id="TestSet") | ||
|
||
def test_PackageVersion_creation(self): | ||
# Check if new PackageVersion is added to database and latest_version of respective Package is updated | ||
testUser = User(username='kimjongun', password='katyperry') | ||
testUser.save() | ||
packageA = Package.objects.get(slug="a") | ||
packageA.create_version(testUser, "This version uses Hong Yi") | ||
myPV = PackageVersion.objects.get(package=packageA) | ||
self.assertEqual(myPV.article_data, "Hong Yi") | ||
self.assertEqual(myPV.version_description, "This version uses Hong Yi") | ||
self.assertEqual(myPV.creator.get_username(), "kimjongun") | ||
self.assertEqual(packageA.latest_version, myPV) | ||
|
||
|
||
# Check handling of multiple PackageVersions | ||
packageA.cached_article_preview = "HONG YEET" | ||
packageA.create_version(testUser, "This version uses HONG YEET") # Now we should have 2 different versions of packageA | ||
myPV = PackageVersion.objects.last() | ||
self.assertEqual(len(PackageVersion.objects.filter(package=packageA).all()), 2) | ||
self.assertEqual(myPV.article_data, "HONG YEET") | ||
self.assertEqual(myPV.version_description, "This version uses HONG YEET") | ||
self.assertEqual(myPV.creator.get_username(), "kimjongun") | ||
|
||
# Check if able to retrieve publish_date of latest PackageVersion | ||
latestPV = packageA.latest_version | ||
self.assertEqual(latestPV.article_data, "HONG YEET") | ||
|