Repository: fossasia/open-event-server

Issue:
Add Event Sub Topic API to dredd testing
parent issue #3870


Discussion:
Hi @magdalenesuo!

Looks like you're missing some information we'll need to replicate this issue.

The easier it is for us to decipher an issue with the info provided,
the more likely it is that we'll be able to help.

Please make sure you have the following information in this issue:

1. The current (incorrect) behavior you're seeing.
2. The behavior you expect.
3. The OS version, browser, app, device you use.
4. A [short, self-contained example](http://sscce.org/).

Resolving patch:
diff --git a/app/factories/event_sub_topic.py b/app/factories/event_sub_topic.py
new file mode 100644
--- /dev/null
+++ b/app/factories/event_sub_topic.py
@@ -0,0 +1,14 @@
+import factory
+from app.models.event_sub_topic import db, EventSubTopic
+from app.factories.event_topic import EventTopicFactory
+import app.factories.common as common
+
+
+class EventSubTopicFactory(factory.alchemy.SQLAlchemyModelFactory):
+    class Meta:
+        model = EventSubTopic
+        sqlalchemy_session = db.session
+
+    event_topic = factory.RelatedFactory(EventTopicFactory)
+    name = common.string_
+    slug = common.slug_


Test patch:
diff --git a/tests/hook_main.py b/tests/hook_main.py
--- a/tests/hook_main.py
+++ b/tests/hook_main.py
@@ -24,6 +24,7 @@
 from app.factories.event_type import EventTypeFactory
 from app.factories.discount_code import DiscountCodeFactory
 from app.factories.event_topic import EventTopicFactory
+from app.factories.event_sub_topic import EventSubTopicFactory
 
 stash = {}
 api_username = "open_event_test_user@fossasia.org"
@@ -1256,7 +1257,10 @@ def event_sub_topic_get_list(transaction):
     :param transaction:
     :return:
     """
-    transaction['skip'] = True
+    with stash['app'].app_context():
+        event_sub_topic = EventSubTopicFactory()
+        db.session.add(event_sub_topic)
+        db.session.commit()
 
 
 @hooks.before("Event Sub Topics > Event Sub Topics Collection > Create Event Sub Topic")
@@ -1266,7 +1270,10 @@ def event_sub_topic_post(transaction):
     :param transaction:
     :return:
     """
-    transaction['skip'] = True
+    with stash['app'].app_context():
+        event_topic = EventTopicFactory()
+        db.session.add(event_topic)
+        db.session.commit()
 
 
 @hooks.before("Event Sub Topics > Event Sub Topic Details > Event Sub Topic Details")
@@ -1276,7 +1283,10 @@ def event_sub_topic_get_detail(transaction):
     :param transaction:
     :return:
     """
-    transaction['skip'] = True
+    with stash['app'].app_context():
+        event_sub_topic = EventSubTopicFactory()
+        db.session.add(event_sub_topic)
+        db.session.commit()
 
 
 @hooks.before("Event Sub Topics > Event Sub Topic Details > Update Event Sub Topic")
@@ -1286,7 +1296,10 @@ def event_sub_topic_patch(transaction):
     :param transaction:
     :return:
     """
-    transaction['skip'] = True
+    with stash['app'].app_context():
+        event_sub_topic = EventSubTopicFactory()
+        db.session.add(event_sub_topic)
+        db.session.commit()
 
 
 @hooks.before("Event Sub Topics > Event Sub Topic Details > Delete Event Sub Topic")
@@ -1296,4 +1309,7 @@ def event_sub_topic_delete(transaction):
     :param transaction:
     :return:
     """
-    transaction['skip'] = True
+    with stash['app'].app_context():
+        event_sub_topic = EventSubTopicFactory()
+        db.session.add(event_sub_topic)
+        db.session.commit()